package com.zx.demo.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.net.InetAddress;

/**
 * @author Zx
 * @date 2020/12/23 19:57
 * @modified By:
 */
@RestController
public class HelloController {
    private final StringRedisTemplate redisTemplate;

    public HelloController(StringRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    private Logger logger = LoggerFactory.getLogger("logstash");

    @GetMapping("/hello")
    public String hello() throws Exception {
//        Long views = redisTemplate.opsForValue().increment("views");
        Long views = 1L;
//        String ip = InetAddress.getLocalHost().getHostAddress();
        String ip = "22213";

//        System.out.println(ip);
        logger.info(ip);
        return "hello world: " + views + "=====" + ip;
    }
}
